#include "FrontendState.h"


FrontendState::FrontendState(GameContext& gc)
	:GameState(gc)
{
}


FrontendState::~FrontendState()
{
}


void FrontendState::Load() 
{
	mFont.Load(20);
	mCursor.Load("sword.png");

	mStartButtom1.Load("button_on.png", "button_off.png");
	mStartButtom1.SetPosition(SVector2(200.0f, 500.0f));
	mStartButtom1.SetText("Level 1", 255, 255, 255);

	mStartButtom2.Load("button_on.png", "button_off.png");
	mStartButtom2.SetPosition(SVector2(200.0f, 550.0f));
	mStartButtom2.SetText("Level 2", 255, 255, 255);

	mQuitButtom.Load("button_on.png", "button_off.png");
	mQuitButtom.SetPosition(SVector2(200.0f, 600.0f));
	mQuitButtom.SetText("a", 255, 255, 255);
}

void FrontendState::Unload() 
{
	mFont.Unload();
	mCursor.Unload();
	mStartButtom1.Unload();
	mStartButtom2.Unload();
	mQuitButtom.Unload();
}

NextState FrontendState::Update(float deltaTime)
{
	mCursor.Update(deltaTime);
	mStartButtom1.Update(deltaTime);
	mStartButtom2.Update(deltaTime);
	mQuitButtom.Update(deltaTime);

	NextState nextState = None;
	if(mStartButtom1.IsPressed())
	{
		mGameContext.SetLevel(1);
		nextState = Gameplay;
	}
	else if(mStartButtom2.IsPressed())
	{
		mGameContext.SetLevel(2);
		nextState = Gameplay;
	}
	else if(mQuitButtom.IsPressed())
	{
		nextState = Quit;
	}
	return nextState;
	
}

void FrontendState::Render() 
{
	mFont.Print("A Link to Pikachu's Past", 100, 100);
	mCursor.Render();
	mStartButtom1.Render();
	mStartButtom2.Render();
	mQuitButtom.Render();
}